<?php

require_once 'ActionFramework/start.php';
require_once 'actions/login_abstract.cls.php';

class LoginByUrlAction extends AbstractLoginAction {
	
	const INPUT_SECRET = 'secret';
	
	public function __construct() {
		parent::__construct();
		$this->add_input(new Input(LoginByUrlAction::INPUT_SECRET));
	}
	
	public function verify_credentials(Array $request) {
		global $DB;
		return $DB->get_login_by_url_user($request[LoginByUrlAction::INPUT_SECRET]);
	}
	
	public function redirect_invalid_credentials() {
		return r(new StartAction('The url has expired or is not correctly copied.'))->trigger(array());
	}
	
}

?>